package class06;

//打印n 层汉诺塔从左边移动到最右边的全过程  步数 2^N-1
public class Code01_Hanoi {

    static void printHanoi(int n) {
        func(n, "left", "right", "mid");
    }

    static void func(int n, String from, String to, String other) {
        if (n == 1) {
            System.out.println("Move 1 from " + from + " to " + to);
        } else {
            func(n - 1, from, other, to);
            System.out.println("Move " + n + " from " + from + " to " + to);
            func(n - 1, other, to, from);
        }
    }

    public static void main(String[] args) {
        printHanoi(3);
    }

}
